package com.scada.model.result;


import java.io.Serializable;
import java.util.List;

public class PageInfo<T> implements Serializable {
	
    /**
	 * @fieldName: serialVersionUID
	 * @fieldType: long
	 * @Description: TODO
	 */
	private static final long serialVersionUID = 1882965792578587198L;
	
	private int start;//datatables 参数
	
	private int length;// datatables 参数 自动获取后赋值到pageSize
	
	private int pageSize = 10;// 每页显示多少条
    
    private int currentPage = 1;// 当前页数
    
    private int recordsTotal;// 数据总数
    
    private List<T> data;
    
    private Object condition;
    
    private String draw;
    
    private String size;

    
    public String getSize() {
		return size;
	}

	public void setSize(String size) {
		this.size = size;
	}

	public PageInfo() {
    }

    public int getLength() {
		return length;
	}


	public void setLength(int length) {
		this.length = length;
		this.pageSize = length;
	}


	public String getDraw() {
		return draw;
	}


	public void setDraw(String draw) {
		this.draw = draw;
	}


	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		
		this.pageSize = pageSize;
	}

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}
	
	public int getCurrentPage() {
        return this.currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getRecordsTotal() {
    	
    	 return this.recordsTotal / this.pageSize + (this.recordsTotal % this.pageSize == 0?0:1);
	}

	public void setRecordsTotal(int recordsTotal) {
		this.recordsTotal = recordsTotal;
	}

    public List<T> getData() {
		return data;
	}

	public void setData(List<T> data) {
		this.data = data;
	}

	public int getRecordsFiltered() {
        return this.recordsTotal;
    }
    
    public int getPages() {
        return recordsTotal/this.pageSize;
    }
    
    public int getPageNum(){
    	 return (start/this.pageSize)+1;
    }

    public int getStartRow() {
        return (this.currentPage - 1) * this.pageSize;
    }

    public int getEndRow() {
        return this.currentPage * this.pageSize - 1;
    }

    public int getStartIndex() {
        return (this.currentPage - 1) * this.pageSize;
    }

    public Object getCondition() {
        return this.condition;
    }

    public void setCondition(Object condition) {
        this.condition = condition;
    }

    
    
}
